<template>
  <div>
    <h1>商品展示</h1>
    <table>
      <tr>
        <td>商品</td>
        <td>价格</td>
        <td>展示</td>
        <td>加入购物车</td>
      </tr>
      <tr v-for="i in goods">
        <td>{{i.name}}</td>
        <td>{{i.price}}</td>
        <td>
          <img :src="'http://127.0.0.1:8000'+i.pic" alt="" width="200px">
        </td>
        <td>
          <button @click="form.num--">-</button>
          <input type="text" :v-model="form.num">
          <button @click="form.num++">+</button>
          <button>确定</button>
        </td>
      </tr>
    </table>
    <button v-for="i in num1" @click="goods_show(i)">{{i}}</button>

  </div>

</template>

<script>
export default {
  name: "qgoods",
  data(){
    return{
      goods:[],
      form:{num:0,qusers:localStorage.getItem('userid')},

    }
  },
  methods:{
    goods_show(i){
      this.$axios.get("users/Goods_API/?cpage="+i)
      .then(i=>{
        this.goods = i.data.list
        this.num1 = i.data.num
      })
    },
    car(){
      this.$axios.post("users/Car_API/",this.form)
    }
  },
  mounted() {
    this.goods_show(1)
  }
}
</script>

<style scoped>

</style>
